<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.8"></script>
    <title>vue6事件修饰符</title>
  </head>
  <body>
    <div id="app">
        <!-- prevent可以阻止a链接的跳转,表单的提交等  vue中的事件修饰符号 -->
        <!-- stop可以阻止事件冒泡    事件冒泡指的是 -->
      <a href="http://www.baidu.com" @click.prevent="clickPrint">跳转到百度首页</a>
      <hr>

      <div style="height: 150px; background-color:red; padding-left: 100px; line-height: 150px;" @click="divHandler">
        <button @click.stop="btnHandler">按钮</button>
      </div>
    </div>

    <script>
      const vm = new Vue({
        el: "#app",
        data: {},
        methods: {
            clickPrint(e){
                console.log("我点击了这个a标签");
                // e.preventDefault();     //原生写法
            },
            btnHandler(e){
                //e.stopPropagation();
                console.log('btnHandler');
            }, 
            divHandler(){
                console.log('divHandler');
            },
           

        },
      });
    </script>
  </body>
</html>
